﻿using PagedList;
using System.Collections.Generic;

namespace Web.Core.Extensions
{
    public static class PagedListExtension
    {
        public static IPagedList<T> ToPagedList<T>(this Ayatta.Contract.Domain.PagedList<T> list, int index, int size)
        {
            return new StaticPagedList<T>(list.Data, index, size, list.Total);
        }

        public static StaticPagedList<T, TExtra> ToPagedList<T, TExtra>(this Ayatta.Contract.Domain.PagedList<T, TExtra> list, int index, int size)
        {
            return new StaticPagedList<T, TExtra>(list.Data, index, size, list.Total, list.Extra);
        }
    }

    public class StaticPagedList<T, TExtra> : StaticPagedList<T>
    {
        public TExtra Extra { get; set; }


        public StaticPagedList(IEnumerable<T> data, int page, int size, int total, TExtra extra)
            : base(data, page, size, total)
        {
            Extra = extra;
        }

    }

}